package com.coincalf.service.impl;

import com.coincalf.dto.TradeAreaDTO;
import com.coincalf.entity.TradeArea;
import com.coincalf.framework.enums.TradeAreaType;
import com.coincalf.mapper.TradeAreaMapper;
import com.coincalf.service.TradeAreaService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 交易区 服务实现类
 * </p>
 *
 * @author qiang
 * @since 2018-05-12
 */
@Service
public class TradeAreaServiceImpl extends ServiceImpl<TradeAreaMapper, TradeArea> implements TradeAreaService {

    /**
     * 查询交易区域(缓存2分钟)
     *
     * @param areaId 交易区域ID
     * @return
     */
    @Override
    public TradeAreaDTO queryTradeAreaFromCache(long areaId) {
        return baseMapper.queryById(areaId);
    }

    /**
     * 根据类型查询交易区域
     *
     * @param tradeAreaType 交易区域
     * @return
     */
    @Override
    public List<TradeAreaDTO> queryByType(TradeAreaType tradeAreaType) {
        return baseMapper.queryByType(tradeAreaType.getCode());
    }
}
